package com.tank.demo.strategy.Impl;

import com.tank.demo.abstractFactory.BaseBullet;
import com.tank.demo.abstractFactory.BaseTank;
import com.tank.demo.facadeAndMediator.GameModel;
import com.tank.demo.myenum.DirEnum;
import com.tank.demo.strategy.FireStrategy;
import com.tank.demo.utils.ResourceMgr;
import lombok.*;

@Getter
@Setter
@NoArgsConstructor
public class FourDirFireStrategyImpl implements FireStrategy {
    @Override
    public void fire(BaseTank tank, BaseBullet bullet) {

        GameModel.getInstance().add(GameModel.gameAbstractFactory.createBullet(tank.getX() + tank.width / 2 - bullet.width / 2, tank.getY() - bullet.height, DirEnum.UP,   tank.getGroup()));
        GameModel.getInstance().add(GameModel.gameAbstractFactory.createBullet(tank.getX() + tank.width / 2 - bullet.width / 2, tank.getY() + tank.height, DirEnum.DOWN,  tank.getGroup()));
        GameModel.getInstance().add(GameModel.gameAbstractFactory.createBullet(tank.getX() - ResourceMgr.bulletL.getWidth(), tank.getY() + tank.height / 2 - ResourceMgr.bulletL.getHeight() / 2, DirEnum.LEFT,   tank.getGroup()));
        GameModel.getInstance().add(GameModel.gameAbstractFactory.createBullet(tank.getX() + tank.width, tank.getY() + tank.height / 2 - ResourceMgr.bulletL.getHeight() / 2, DirEnum.RIGHT,  tank.getGroup()));
    }
}
